package linter.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import linter.POJO.DO.ClassFile;
import linter.mapper.ClassFileMapper;
import linter.service.ClassFileService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import static linter.custom.CustomResultType.SAVE_NOT_ERROR;
import static linter.custom.CustomResultType.SAVE_SUCCESS;

/**
* @author 北煜
* @description 针对表【class_file】的数据库操作Service实现
* @createDate 2024-04-15 21:11:00
*/
@Service
public class ClassFileServiceImpl extends ServiceImpl<ClassFileMapper, ClassFile>
    implements ClassFileService{

    @Resource
    ClassFileMapper classFileMapper;

    @Override
    public String saveByClassId(Long classId, String classType, String className, String url) {
        ClassFile classFile = new ClassFile();
        classFile.setClassImageUrl(url);
        QueryWrapper<ClassFile> queryWrapper = new QueryWrapper<>();
        int flag = classFileMapper.update(classFile, queryWrapper.eq("class_id", classId).eq("class_type", classType)
                .eq("class_name", className));
        return flag != 1 ? SAVE_NOT_ERROR : SAVE_SUCCESS;
    }
}




